package com.ja.openchat.ui.chat.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ja.openchat.R;
import com.ja.openchat.views.UserAvatarView;
import com.zy.openchat.Constants;
import com.zy.openchat.core.manager.TelegramManager;
import com.zy.openchat.core.model.message.MessageReaction;
import com.zy.openchat.core.model.user.UserInfo;

import java.util.List;

public class MessageReactionUserAdapter extends BaseQuickAdapter<MessageReaction, BaseViewHolder> {


    public MessageReactionUserAdapter(@Nullable List<MessageReaction> data) {
        super(R.layout.item_message_reaction_user, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, MessageReaction messageReaction) {
        UserAvatarView userLogo = helper.getView(R.id.userLogo);
        userLogo.showUser(messageReaction.userId);
        ImageView emojiImage = helper.getView(R.id.emojiImage);
        emojiImage.setImageDrawable(Constants.getReactionDrawableById(messageReaction.reactionId));
        UserInfo userInfo = UserInfo.getUserInfo(messageReaction.userId);
        if(userInfo!=null){
            helper.setText(R.id.userNameText,userInfo.displayName());
        }else{
            TelegramManager.getTelegramManager().getUserSimpleInfo(messageReaction.userId);
        }
    }
}
